%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/person-app-vulns.app-vuln-totalCount"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 10, 11, 34, 76, 80, 12<br />2: PgSelect[9]<br />3: Connection[13]<br />4: ConnectionItems[15]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 13, 15, 12, 34, 76<br /><br />ROOT Connectionᐸ9ᐳ[13]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 12, 34, 76<br /><br />ROOT __Item{3}ᐸ15ᐳ[18]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 19, 12, 34, 76<br /><br />ROOT PgSelectSingle{3}ᐸpeopleᐳ[19]<br />1: <br />ᐳ: 20, 21<br />2: PgUnionAll[22]<br />3: Connection[26]<br />4: ConnectionItems[27]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 34, 12, 76<br /><br />ROOT __Item{6}ᐸ27ᐳ[30]"):::bucket
    Bucket7("Bucket 7 (polymorphic)<br />__typename: Access[37]<br />Deps: 37, 12, 38, 76"):::bucket
    Bucket8("Bucket 8 (polymorphicPartition)<br />|AwsApplication<br />Deps: 12, 38, 76<br />ᐳAwsApplication<br /><br />1: PgSelect[39]<br />2: PgSelectRows[44]<br />ᐳ: 43, 45, 54<br />3: PgUnionAll[66]<br />ᐳ: 77, 67, 70"):::bucket
    Bucket9("Bucket 9 (polymorphicPartition)<br />|GcpApplication<br />Deps: 12, 38, 76<br />ᐳGcpApplication<br /><br />1: PgSelect[47]<br />2: PgSelectRows[52]<br />ᐳ: 51, 53, 60<br />3: PgUnionAll[71]<br />ᐳ: 79, 72, 75"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket6
    Bucket6 --> Bucket7
    Bucket7 --> Bucket8 & Bucket9

    %% plan dependencies
    PgSelect9[["PgSelect[9∈0] ➊<br />ᐸpeopleᐳ<br />More deps:<br />- Object[12]<br />- Constantᐸ4ᐳ[80]"]]:::plan
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 6"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    Connection13[["Connection[13∈0] ➊<br />ᐸ9ᐳ<br />More deps:<br />- Constantᐸ4ᐳ[80]"]]:::plan
    PgSelect9 --> Connection13
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    ConnectionItems15[["ConnectionItems[15∈0] ➊"]]:::plan
    Connection13 --> ConnectionItems15
    __Item18[/"__Item[18∈3]<br />ᐸ15ᐳ"\]:::itemplan
    ConnectionItems15 ==> __Item18
    PgSelectSingle19{{"PgSelectSingle[19∈3]<br />ᐸpeopleᐳ"}}:::plan
    __Item18 --> PgSelectSingle19
    PgUnionAll22[["PgUnionAll[22∈4]<br />ᐸAwsApplication,GcpApplicationᐳ<br />More deps:<br />- Object[12]"]]:::plan
    PgClassExpression20{{"PgClassExpression[20∈4]<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    PgClassExpression20 --> PgUnionAll22
    PgSelectSingle19 --> PgClassExpression20
    PgClassExpression21{{"PgClassExpression[21∈4]<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgSelectSingle19 --> PgClassExpression21
    Connection26[["Connection[26∈4]<br />ᐸ22ᐳ"]]:::plan
    PgUnionAll22 --> Connection26
    ConnectionItems27[["ConnectionItems[27∈4]"]]:::plan
    Connection26 --> ConnectionItems27
    List35{{"List[35∈6]<br />ᐸ32,33,34ᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[34]"}}:::plan
    Access32{{"Access[32∈6]<br />ᐸ30.0ᐳ"}}:::plan
    Access33{{"Access[33∈6]<br />ᐸ30.1ᐳ"}}:::plan
    Access32 & Access33 --> List35
    __Item30[/"__Item[30∈6]<br />ᐸ27ᐳ"\]:::itemplan
    ConnectionItems27 ==> __Item30
    __Item30 --> Access32
    __Item30 --> Access33
    Lambda36{{"Lambda[36∈6]<br />ᐸtoSpecifierᐳ"}}:::plan
    List35 --> Lambda36
    Access37{{"Access[37∈6]<br />ᐸ36.__typenameᐳ"}}:::plan
    Lambda36 --> Access37
    Access38{{"Access[38∈6]<br />ᐸ36.idᐳ"}}:::plan
    Lambda36 --> Access38
    PgSelect39[["PgSelect[39∈8]<br />ᐸaws_applicationsᐳ<br />ᐳAwsApplication<br />More deps:<br />- Object[12]"]]:::plan
    Access38 --> PgSelect39
    PgUnionAll66[["PgUnionAll[66∈8]^<br />ᐸFirstPartyVulnerability,ThirdPartyVulnerabilityᐳ<br />More deps:<br />- Object[12]"]]:::plan
    PgClassExpression54{{"PgClassExpression[54∈8]^<br />ᐸ__aws_appl...ons__.”id”ᐳ"}}:::plan
    PgClassExpression54 --> PgUnionAll66
    First43{{"First[43∈8]^"}}:::plan
    PgSelectRows44[["PgSelectRows[44∈8]^"]]:::plan
    PgSelectRows44 --> First43
    PgSelect39 --> PgSelectRows44
    PgSelectSingle45{{"PgSelectSingle[45∈8]^<br />ᐸaws_applicationsᐳ"}}:::plan
    First43 --> PgSelectSingle45
    PgSelectSingle45 --> PgClassExpression54
    First67{{"First[67∈8]^"}}:::plan
    Access77{{"Access[77∈8]^<br />ᐸ66.itemsᐳ"}}:::plan
    Access77 --> First67
    PgClassExpression70{{"PgClassExpression[70∈8]^<br />ᐸcount(*)ᐳ"}}:::plan
    First67 --> PgClassExpression70
    PgUnionAll66 --> Access77
    PgSelect47[["PgSelect[47∈9]<br />ᐸgcp_applicationsᐳ<br />ᐳGcpApplication<br />More deps:<br />- Object[12]"]]:::plan
    Access38 --> PgSelect47
    PgUnionAll71[["PgUnionAll[71∈9]^<br />ᐸFirstPartyVulnerability,ThirdPartyVulnerabilityᐳ<br />More deps:<br />- Object[12]"]]:::plan
    PgClassExpression60{{"PgClassExpression[60∈9]^<br />ᐸ__gcp_appl...ons__.”id”ᐳ"}}:::plan
    PgClassExpression60 --> PgUnionAll71
    First51{{"First[51∈9]^"}}:::plan
    PgSelectRows52[["PgSelectRows[52∈9]^"]]:::plan
    PgSelectRows52 --> First51
    PgSelect47 --> PgSelectRows52
    PgSelectSingle53{{"PgSelectSingle[53∈9]^<br />ᐸgcp_applicationsᐳ"}}:::plan
    First51 --> PgSelectSingle53
    PgSelectSingle53 --> PgClassExpression60
    First72{{"First[72∈9]^"}}:::plan
    Access79{{"Access[79∈9]^<br />ᐸ71.itemsᐳ"}}:::plan
    Access79 --> First72
    PgClassExpression75{{"PgClassExpression[75∈9]^<br />ᐸcount(*)ᐳ"}}:::plan
    First72 --> PgClassExpression75
    PgUnionAll71 --> Access79

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect9,Access10,Access11,Object12,Connection13,ConnectionItems15 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item18,PgSelectSingle19 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression20,PgClassExpression21,PgUnionAll22,Connection26,ConnectionItems27 bucket4
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item30,Access32,Access33,List35,Lambda36,Access37,Access38 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgSelect39,First43,PgSelectRows44,PgSelectSingle45,PgClassExpression54,PgUnionAll66,First67,PgClassExpression70,Access77 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgSelect47,First51,PgSelectRows52,PgSelectSingle53,PgClassExpression60,PgUnionAll71,First72,PgClassExpression75,Access79 bucket9

